#include "box.h"
#include "ui_box.h"

box::box(QWidget *parent):
    QMainWindow(parent),
    ui(new Ui::box),round(1)
{
    ui->setupUi(this);
    this->setGeometry(QRect(600,230,555,555));
}

box::~box()
{
    delete ui;
}

void box::paintEvent(QPaintEvent *){
    QPainter painter(this);
    painter.setPen(Qt::black);
    painter.setBrush(Qt::gray);
    painter.drawRect(30,30,500,500);

    painter.setPen(Qt::black);
    painter.setBrush(Qt::black);
    painter.drawPixmap(40,40,480,480,QPixmap(":/images/myiamges/background.jpg"));

    if(round==1){
        init_1st();
        }
    if(round==2){
        init_2nd();
        }

    for(int i=0;i<5;i++){

        painter.setPen(Qt::black);
        painter.setBrush(Qt::gray);
        painter.drawPixmap(boxrect[i],QPixmap(":/images/myiamges/boom.jpg"));
    }
        painter.setOpacity(0.85);
        painter.setPen(Qt::black);
        painter.setBrush(Qt::yellow);
        painter.drawPixmap(holes[0],QPixmap(":/images/myiamges/stone.jpg"));

        painter.setPen(Qt::black);
        painter.setBrush(Qt::yellow);
        painter.drawPixmap(holes[1],QPixmap(":/images/myiamges/ice.jpg"));

        painter.setPen(Qt::black);
        painter.setBrush(Qt::yellow);
        painter.drawPixmap(holes[2],QPixmap(":/images/myiamges/water.jpg"));

        painter.setPen(Qt::black);
        painter.setBrush(Qt::yellow);
        painter.drawPixmap(holes[3],QPixmap(":/images/myiamges/wind.jpg"));
        painter.setPen(Qt::black);
        painter.setBrush(Qt::yellow);
        painter.drawPixmap(holes[4],QPixmap(":/images/myiamges/thunder.jpg"));

    for(int i=0;i<37;i++){
        painter.setOpacity(0.3);
        painter.setPen(Qt::black);
        painter.setBrush(Qt::red);
        painter.drawRect(wall[i]);
    }
//    painter.setOpacity(0.45);
//    painter.setPen(Qt::blue);
//    for(int i=2;i<=12;i++){
//        painter.drawLine(40,i*40,520,i*40);
//        painter.drawLine(i*40,40,i*40,520);
//    }
    painter.setOpacity(1);
    painter.drawPixmap(manrect,QPixmap(":/images/myiamges/keli.jpg"));

    QFont font1("Courier",30);
    painter.setFont(font1);
    painter.setPen(Qt::black);
    painter.drawText(220,100,sDisplay);
}
